package com.lyhlmj.oop_client.Style.Buttons.WaitFrameButton;

import com.lyhlmj.oop_client.ClientOperation.ClientUtil.Client;
import com.lyhlmj.oop_client.Style.Buttons.GeneralButton;
import com.lyhlmj.oop_client.Utils.Request;
import org.json.JSONObject;

import java.awt.*;

public class LogoutButton extends GeneralButton {
    private Client client = Client.client;
    private Window owner;

    public LogoutButton(String str, Window owner) {
        super(str);
        this.owner = owner;
    }

    public void doLogout() {
        //        向后端发送登出信号
        JSONObject jsonReq = Request.getJsonObject("logout", "username", client.getUsername());
        try {
            client.send(jsonReq);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("登出过程出现错误！\n");
        }
    }
}
